#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

class Solution {
public:
    string convertToBase7(int num) {
        if(num==0) return "0";
        std::string res="";
        int abs_num=std::abs(num);
        while(abs_num>0){
            int bit=abs_num%7;
            res=std::to_string(bit)+res;
            abs_num=abs_num/7;
        }
        if(num<0){
            res="-"+res;
        }
        return res;
    }
};

#include <iostream>
#include <string>

int hexToDecimal(const std::string& hexStr) {
    int decimalValue = 0;
    int power = 1;
    int len = hexStr.length();

    for (int i = len - 1; i >= 0; i--) {
        int digitValue;
        if (hexStr[i] >= '0' && hexStr[i] <= '9') {
            digitValue = hexStr[i] - '0';
        } else if (hexStr[i] >= 'A' && hexStr[i] <= 'F') {
            digitValue = hexStr[i] - 'A' + 10;
        } else if (hexStr[i] >= 'a' && hexStr[i] <= 'f') {
            digitValue = hexStr[i] - 'a' + 10;
        }
        decimalValue += digitValue * power;
        power *= 16;
    }
    return decimalValue;
}